<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>添加公众号·思通投研·让数据驱动投资价值!</title>
	<link href="${pageContext.request.contextPath }/img/webLogoIcon.png" rel="shortcut icon">
    <link href="${pageContext.request.contextPath }/css/bootstrap.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/font-awesome.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/custom.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/animate.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/style.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datatables.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/css/datepicker3.css" rel="stylesheet">
	<link href="${pageContext.request.contextPath }/css/toastr.min.css" rel="stylesheet" />

    
    <style>
		.left{
		    float:left;
		    width:33%;
		}
		.form-horizontal{
			width: 95%;
		}
		.form-control {
			display: inline;
		}
		.col-sm-2{
			height: 50px;
		}
		.col-sm-10 {
		    width: 50%;
		}
	</style>
</head>

<body>

    <div id="wrapper">

        <nav class="navbar-default navbar-static-side" role="navigation">
<%
            	if(request.getParameter("flag").equals("0"))
            	{
            		request.setAttribute("LEFT", "wechat_list");
            	}else if(request.getParameter("flag").equals("1"))
            	{
            		request.setAttribute("LEFT", "sina_list");
            	}
            %>
			<%@include file="left.jsp"%>
        </nav>

        <div id="page-wrapper" class="gray-bg">
        <div class="row border-bottom">
        <jsp:include page="head.jsp" flush="true" /> 
        </div>
            <div class="row wrapper border-bottom white-bg page-heading">
                <div class="col-lg-10">
                	<c:if test="${flag=='0'}">
	            		<h2>添加微信公众号</h2>
	            	</c:if>
	            	<c:if test="${flag=='1'}">
	            		<h2>添加新浪微博</h2>
	            	</c:if>
                    
                </div>
            </div>
        <div class="wrapper wrapper-content">
            <div class="ibox-content">
            	<c:if test="${flag=='0'}">
            		<button class="btn btn-white pull-right" onclick="window.location.href = '${pageContext.request.contextPath}/social/wechat_list'" type="button">返回</button>
            	</c:if>
            	<c:if test="${flag=='1'}">
            		<button class="btn btn-white pull-right" onclick="window.location.href = '${pageContext.request.contextPath}/social/sina_list'" type="button">返回</button>
            	</c:if>
                <div class="table-responsive" style="margin-top: 5%;">
                	
                    <div class="panel-body" style="margin-left:25%">
                           <fieldset class="form-horizontal">
							   <div class="form-group"><label class="col-sm-3 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>公众号昵称/微博昵称:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="name" style="width: 88%;" placeholder="请输入公众号昵称/微博昵称"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label"><span style="color:red;font-size:16px;line-height:0px;">*</span>公众号/微博官网:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="alias" style="width: 88%;" placeholder="请输入公众号/微博官网"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label"><c:if test="${flag=='1'}"><span style="color:red;font-size:16px;line-height:0px;">*</span></c:if>公众号源/微博资讯来源:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="origin" style="width: 88%;" placeholder="请输入公众号源/微博资讯来源"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label">公众头像/微博头像URL:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="avatar_url" style="width: 88%;" placeholder="请输入公众头像/微博头像URL"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label">公众号二维码URL:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="qrcode_url" style="width: 88%;" placeholder="请输入公众号二维码URL"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label">公众号简介:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="introduction" style="width: 88%;" placeholder="请输入公众号简介"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label">公众号粉丝量:</label>
                                   <div class="col-sm-10"><input type="text" class="form-control" id="fans_num_estimate" style="width: 88%;" placeholder="请输入公众号粉丝量"></div>
                               </div>
                               <div class="form-group"><label class="col-sm-3 control-label">网站类型:</label>
                                   <div class="col-sm-10">
                                   <select class="form-control" style="display: inline;width: 35%;"
											id="type">
											<option value="1" ${flag == '0' ? 'selected' : ''}>微信公众号</option>
											<option value="2" ${flag == '1' ? 'selected' : ''}>新浪微博</option>
									</select>
                                   </div>
                               </div>
                           </fieldset>
                           <c:if test="${flag=='0'}">
                               <button class="btn btn-primary"style="margin-left: 45%;margin-top: 2%;" onclick="addSocial0()" type="button">确定添加站点</button>
                           </c:if>
                           <c:if test="${flag=='1'}">
                               <button class="btn btn-primary"style="margin-left: 45%;margin-top: 2%;" onclick="addSocial1()" type="button">确定添加站点</button>
                           </c:if>
                       </div>
                   </div>
                </div>
            </div>
			<jsp:include page="footer.jsp" flush="true" />
        </div>
        </div>



    <!-- Mainly scripts -->
    <script src="${pageContext.request.contextPath }/js/jquery-2.1.1.js"></script>
    <script src="${pageContext.request.contextPath }/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.metisMenu.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.slimscroll.min.js"></script>
    <script src="${pageContext.request.contextPath }/js/jquery.jeditable.js"></script>
    <script src="${pageContext.request.contextPath }/js/datatables.min.js"></script>
    
    <!-- Peity -->
    <script src="${pageContext.request.contextPath }/js/jquery.peity.min.js"></script>

    <!-- Custom and plugin javascript -->
    <script src="${pageContext.request.contextPath }/js/inspinia.js"></script>
    <script src="${pageContext.request.contextPath }/js/pace.min.js"></script>

    <!-- Peity -->
    <script src="${pageContext.request.contextPath }/js/peity-demo.js"></script>

	<!-- toastr -->
	<script src="${pageContext.request.contextPath }/js/plugins/toastr/toastr.min.js"></script>

    <!-- Page-Level Scripts -->
    <script>
    function addSocial0(){
    	
    	if($("#name").val()==null||$("#name").val()=="")
    	{
    		toastr.error('请填写公众号昵称/微博昵称')
    		return;
    	}else if($("#alias").val()==null||$("#alias").val()=="")
    	{
    		toastr.error('请填写公众号/微博官网')
    		return;
    	}
    	
    	$.ajax({
    		url : "${pageContext.request.contextPath}/social/add_social",
    		type : "post",
    		data : {
    			name : $("#name").val(),
    			alias : $("#alias").val(),
    			origin : $("#origin").val(),
    			avatar_url : $("#avatar_url").val(),
    			qrcode_url : $("#qrcode_url").val(),
    			introduction : $("#introduction").val(),
    			fans_num_estimate : $("#fans_num_estimate").val(),
    			type : $("#type").val()
    		},
    		success : function(res) {
    			console.log(res)
    			if (res.status == 200) {
    				toastr.success(res.msg);
    				window.location.href = "${pageContext.request.contextPath}/social/wechat_list"
    			} else {
    				toastr.error(res.msg);
    			}
    		},
    		error : function(e) {
    			toastr.error(res.msg);
    			window.clearInterval(timer);
    		}
    	});
    }
	function addSocial1(){
    	
    	if($("#name").val()==null||$("#name").val()=="")
    	{
    		toastr.error('请填写公众号昵称/微博昵称')
    		return;
    	}else if($("#alias").val()==null||$("#alias").val()=="")
    	{
    		toastr.error('请填写公众号/微博官网')
    		return;
    	}else if($("#origin").val()==null||$("#origin").val()=="")
    	{
    		toastr.error('请填写公众号源/微博资讯来源"')
    		return;
    	}
    	
    	$.ajax({
    		url : "${pageContext.request.contextPath}/social/add_social",
    		type : "post",
    		data : {
    			name : $("#name").val(),
    			alias : $("#alias").val(),
    			origin : $("#origin").val(),
    			avatar_url : $("#avatar_url").val(),
    			qrcode_url : $("#qrcode_url").val(),
    			introduction : $("#introduction").val(),
    			fans_num_estimate : $("#fans_num_estimate").val(),
    			type : $("#type").val()
    		},
    		success : function(res) {
    			console.log(res)
    			if (res.status == 200) {
    				alert(res.msg)
    				window.location.href = "${pageContext.request.contextPath}/social/sina_list"
    			} else {
    				alert(res.msg)
    			}
    		},
    		error : function(e) {
    			alert("错误！！");
    			window.clearInterval(timer);
    		}
    	});
    }
	
	
	
	//跑马灯方法 
// 	 function init(){
// 		    //获取标题
// 		    var title=document.title;
// 		    //分割字符串--->字符数组
// 		    var arr=title.split("");
// 		    //删除第一个元素并返回该元素
// 		    var e=arr.shift();
// 		    //把一个对象添加到数组末尾
// 		    arr.push(e);
// 		    //把数组转换成字符串
// 		    var marquee=arr.join("");
// 		    //返回给浏览器
// 		    document.title=marquee;
// 		    //定时一直执行
// 		    window.setTimeout("init()",1000);
// 		}
// 		window.onload=init;
	 
    </script>

</body>

</html>
